package zjut.raymond.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * Reference point
 *
 * @author Raymond
 * @Description 参考点
 *
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "tb_reference_point")
public class ReferencePoint {
    /**
     * Id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * X
     */
    private Integer x;

    /**
     * Y
     */
    private Integer y;


    /**
     * Region id
     */
    private Integer regionId;

    /**
     * Update time
     */
    private Date updateTime;

    public static Integer getXById (List<ReferencePoint> referencePoints, Integer targetId) {
        for (ReferencePoint referencePoint : referencePoints) {
            if (referencePoint.getId().equals(targetId)) {
                return referencePoint.getX();
            }
        }
        return 0;
    }

    public static Integer getYById (List<ReferencePoint> referencePoints, Integer targetId) {
        for (ReferencePoint referencePoint : referencePoints) {
            if (referencePoint.getId().equals(targetId)) {
                return referencePoint.getY();
            }
        }
        return 0;
    }
}
